<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="">
        <input type="text" name="username">
        <input type="password" name="psw">
        <input type="text" name="age">
        <button>提交</button>
    </form>
    <script>
        var searsh = location.search
        var obj = {}
        var str = searsh.substr(1)
        var arr = str.split('&')
        for (var i = 0; i < arr.length; i++) {
            var newArr = arr[i].split('=')
            obj[newArr[0]] = newArr[1]
        }
        console.log(obj);
    </script>
</body>

</html>